//
//  THDataSynchronizeTableViewCell.m
//  TaiHaoCloud
//
//  Created by rzm on 16/6/15.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "DataSynchronizeTableViewCell.h"
//#import "SampuxModelSegView.h"

@interface DataSynchronizeTableViewCell ()


@end

@implementation DataSynchronizeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupSubView];
    }
    return self;
}

- (void)setupSubView
{
    [self layoutIfNeeded];
    CGFloat font = 8.;
    if (IS_IPHONE_4_OR_LESS) {
        font = 12.;
    }else if (IS_IPHONE_5_OR_LESS)
    {
        font = 14.;
    }else if (IS_IPHONE_6)
    {
        font = 14;
    }else
    {
        font = 14;
    }
    UIButton *imageView = [UIButton createButton];
    imageView.frame = CGRectMake(10, (10), 44 - 10*2,(44) - (10)*2);
    [self addSubview:imageView];
    [imageView setImage:imageNamed(@"data_set") forState:UIControlStateNormal];
    imageView.userInteractionEnabled = NO;
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(imageView.right + 10, Sampux6HScale(10), Sampux6WScale(80), (24))];
    nameLabel.font = THFont(font);
    nameLabel.textColor = THWhiteAlplaColor(0.8);
    [self addSubview:nameLabel];
    nameLabel.text = @"数据同步";

    UILabel *yesLab = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - Sampux6HScale(5) - Sampux6WScale(15), (10), Sampux6WScale(15), (24))];
    [self addSubview:yesLab];
    yesLab.text = @"是";
    yesLab.font = THFont(font - 2);
    yesLab.textAlignment = NSTextAlignmentLeft;
    yesLab.textColor = THWhiteAlplaColor(0.8);
    
    self.segment = [[[NSBundle mainBundle] loadNibNamed:@"SampuxCustomSegment" owner:self options:nil]lastObject];
    //    self.segment.delegate = self;
    [self addSubview:self.segment];
  self.segment.origin = CGPointMake(yesLab.left - Sampux6WScale(60) - Sampux6WScale(5), 8);
//    self.segment.frame = CGRectMake(yesLab.left - Sampux6WScale(50) - Sampux6WScale(5), Sampux6HScale(12), Sampux6WScale(0), Sampux6HScale(20));
    self.segment.layer.borderColor = [UIColor blueColor].CGColor;
    self.segment.backgroundColor = [UIColor colorWithHex:0xffC1C1C1];
    UILabel *noLab = [[UILabel alloc]initWithFrame:CGRectMake(self.segment.left - Sampux6WScale(15) - Sampux6WScale(5), (10), Sampux6WScale(15), (24))];
    [self addSubview:noLab];
    noLab.text = @"否";
    noLab.font = THFont(font-2);
    noLab.textAlignment = NSTextAlignmentRight;
    noLab.textColor = THWhiteAlplaColor(0.8);

    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 44, kScreenWidth, 1)];
    [self addSubview:lineView];
    lineView.backgroundColor = THBlackAlplaColor(0.3);
}

- (void)setConfigModel:(SPDeviceConfigModel *)configModel
{
    _configModel = configModel;
    self.segment.configModel = _configModel;
}
@end
